package yf.mall.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;


/**
 *
 *
 * @date Sun May 24 14:16:14 CST 2020
 */
@Getter
public enum AccountTypeEnum {


    CASH(0, "学分"),


    COUPON(1, "津贴"),


    DZ(2, "店主券"),

    DR(3, "达人券"),

    FW(4, "招生券"),

    LY(5, "机构券"),
    FW1(6, "招生券十"),
    LY1(7, "机构券1"),
    FW2(8, "招生券四");

//
//    POINT(2, "积分"),
//
//
//    VOUCHER(3, "换购券"),
//
//
//    EXP(4, "经验值"),
//
//
//    GFIT(5, "捐赠"),
//
//    CLEAR(6, "清货券"),
//
//    WELFARE(7, "公益金");


    int index;
    String value;

    AccountTypeEnum(int index, String value) {
        this.index = index;
        this.value = value;
    }

    public static Map toMap() {
        return Arrays.stream(AccountTypeEnum.values()).collect(Collectors.toMap(AccountTypeEnum::getIndex, AccountTypeEnum::getValue));
    }

    public static String indexOf(int idx) {
        return AccountTypeEnum.values()[idx].getValue();
    }

    public static int nameOf(String name) {
        for (AccountTypeEnum e : AccountTypeEnum.values()) {
            if (e.getValue().equals(name)) {
                return e.getIndex();
            }
        }
        throw new RuntimeException("不存在");
    }

}
